<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.11"/>
<title>Lane Detection for Autonomous Cars: /home/michi/Desktop/UMD/ENPM808X/Midterm/workspace/Lane-Detection-for-Autonomous-Cars/include/LaneDetector.hpp Source File</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<script type="text/javascript">
  $(document).ready(function() { init_search(); });
</script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td id="projectalign" style="padding-left: 0.5em;">
   <div id="projectname">Lane Detection for Autonomous Cars
   </div>
   <div id="projectbrief">Lane Detection Module using C++ and OpenCV</div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.11 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "search",false,'Search');
</script>
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>Main&#160;Page</span></a></li>
      <li><a href="annotated.html"><span>Classes</span></a></li>
      <li class="current"><a href="files.html"><span>Files</span></a></li>
      <li>
        <div id="MSearchBox" class="MSearchBoxInactive">
        <span class="left">
          <img id="MSearchSelect" src="search/mag_sel.png"
               onmouseover="return searchBox.OnSearchSelectShow()"
               onmouseout="return searchBox.OnSearchSelectHide()"
               alt=""/>
          <input type="text" id="MSearchField" value="Search" accesskey="S"
               onfocus="searchBox.OnSearchFieldFocus(true)" 
               onblur="searchBox.OnSearchFieldFocus(false)" 
               onkeyup="searchBox.OnSearchFieldChange(event)"/>
          </span><span class="right">
            <a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.png" alt=""/></a>
          </span>
        </div>
      </li>
    </ul>
  </div>
  <div id="navrow2" class="tabs2">
    <ul class="tablist">
      <li><a href="files.html"><span>File&#160;List</span></a></li>
      <li><a href="globals.html"><span>File&#160;Members</span></a></li>
    </ul>
  </div>
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<div id="nav-path" class="navpath">
  <ul>
<li class="navelem"><a class="el" href="dir_d44c64559bbebec7f509842c48db8b23.html">include</a></li>  </ul>
</div>
</div><!-- top -->
<div class="header">
  <div class="headertitle">
<div class="title">LaneDetector.hpp</div>  </div>
</div><!--header-->
<div class="contents">
<a href="LaneDetector_8hpp.html">Go to the documentation of this file.</a><div class="fragment"><div class="line"><a name="l00001"></a><span class="lineno">    1</span>&#160;</div><div class="line"><a name="l00024"></a><span class="lineno">   24</span>&#160;<span class="preprocessor">#pragma once</span></div><div class="line"><a name="l00025"></a><span class="lineno">   25</span>&#160;<span class="preprocessor">#include &lt;opencv2/highgui/highgui.hpp&gt;</span></div><div class="line"><a name="l00026"></a><span class="lineno">   26</span>&#160;<span class="preprocessor">#include&lt;iostream&gt;</span></div><div class="line"><a name="l00027"></a><span class="lineno">   27</span>&#160;<span class="preprocessor">#include &lt;string&gt;</span></div><div class="line"><a name="l00028"></a><span class="lineno">   28</span>&#160;<span class="preprocessor">#include &lt;vector&gt;</span></div><div class="line"><a name="l00029"></a><span class="lineno">   29</span>&#160;<span class="preprocessor">#include &quot;opencv2/opencv.hpp&quot;</span></div><div class="line"><a name="l00030"></a><span class="lineno">   30</span>&#160;</div><div class="line"><a name="l00037"></a><span class="lineno"><a class="line" href="classLaneDetector.html">   37</a></span>&#160;<span class="keyword">class </span><a class="code" href="classLaneDetector.html">LaneDetector</a> {</div><div class="line"><a name="l00038"></a><span class="lineno">   38</span>&#160; <span class="keyword">private</span>:</div><div class="line"><a name="l00039"></a><span class="lineno">   39</span>&#160;  <span class="keywordtype">double</span> img_size;</div><div class="line"><a name="l00040"></a><span class="lineno">   40</span>&#160;  <span class="keywordtype">double</span> img_center;</div><div class="line"><a name="l00041"></a><span class="lineno">   41</span>&#160;  <span class="keywordtype">bool</span> left_flag = <span class="keyword">false</span>;  <span class="comment">// Tells us if there&#39;s left boundary of lane detected</span></div><div class="line"><a name="l00042"></a><span class="lineno">   42</span>&#160;  <span class="keywordtype">bool</span> right_flag = <span class="keyword">false</span>;  <span class="comment">// Tells us if there&#39;s right boundary of lane detected</span></div><div class="line"><a name="l00043"></a><span class="lineno">   43</span>&#160;  cv::Point right_b;  <span class="comment">// Members of both line equations of the lane boundaries:</span></div><div class="line"><a name="l00044"></a><span class="lineno">   44</span>&#160;  <span class="keywordtype">double</span> right_m;  <span class="comment">// y = m*x + b</span></div><div class="line"><a name="l00045"></a><span class="lineno">   45</span>&#160;  cv::Point left_b;  <span class="comment">//</span></div><div class="line"><a name="l00046"></a><span class="lineno">   46</span>&#160;  <span class="keywordtype">double</span> left_m;  <span class="comment">//</span></div><div class="line"><a name="l00047"></a><span class="lineno">   47</span>&#160;</div><div class="line"><a name="l00048"></a><span class="lineno">   48</span>&#160; <span class="keyword">public</span>:</div><div class="line"><a name="l00049"></a><span class="lineno">   49</span>&#160;  cv::Mat <a class="code" href="classLaneDetector.html#a816d7555c6b7690d7afdd81eb62dd35b">deNoise</a>(cv::Mat inputImage);  <span class="comment">// Apply Gaussian blurring to the input Image</span></div><div class="line"><a name="l00050"></a><span class="lineno">   50</span>&#160;  cv::Mat <a class="code" href="classLaneDetector.html#a8920b291267aad638f8874512fba33cf">edgeDetector</a>(cv::Mat img_noise);  <span class="comment">// Filter the image to obtain only edges</span></div><div class="line"><a name="l00051"></a><span class="lineno">   51</span>&#160;  cv::Mat <a class="code" href="classLaneDetector.html#a64d74d2971d1e14175ef58dfbb391f6d">mask</a>(cv::Mat img_edges);  <span class="comment">// Mask the edges image to only care about ROI</span></div><div class="line"><a name="l00052"></a><span class="lineno">   52</span>&#160;  std::vector&lt;cv::Vec4i&gt; <a class="code" href="classLaneDetector.html#adbbc2f50aee10844aeec12b1fe084fb2">houghLines</a>(cv::Mat img_mask);  <span class="comment">// Detect Hough lines in masked edges image</span></div><div class="line"><a name="l00053"></a><span class="lineno">   53</span>&#160;  std::vector&lt;std::vector&lt;cv::Vec4i&gt; &gt; <a class="code" href="classLaneDetector.html#a8005c489f194eded3bc5a76cfc496c43">lineSeparation</a>(std::vector&lt;cv::Vec4i&gt; lines, cv::Mat img_edges);  <span class="comment">// Sprt detected lines by their slope into right and left lines</span></div><div class="line"><a name="l00054"></a><span class="lineno">   54</span>&#160;  std::vector&lt;cv::Point&gt; <a class="code" href="classLaneDetector.html#ac9a862f41a23ab0c3bfed2ce512a56d8">regression</a>(std::vector&lt;std::vector&lt;cv::Vec4i&gt; &gt; left_right_lines, cv::Mat inputImage);  <span class="comment">// Get only one line for each side of the lane</span></div><div class="line"><a name="l00055"></a><span class="lineno">   55</span>&#160;  std::string <a class="code" href="classLaneDetector.html#a84053373ae184e752f023658fb187241">predictTurn</a>();  <span class="comment">// Determine if the lane is turning or not by calculating the position of the vanishing point</span></div><div class="line"><a name="l00056"></a><span class="lineno">   56</span>&#160;  <span class="keywordtype">int</span> <a class="code" href="classLaneDetector.html#a9564c3349f0fa5a7da7968b9461e2730">plotLane</a>(cv::Mat inputImage, std::vector&lt;cv::Point&gt;, std::string turn);  <span class="comment">// Plot the resultant lane and turn prediction in the frame.</span></div><div class="line"><a name="l00057"></a><span class="lineno">   57</span>&#160;};</div><div class="ttc" id="classLaneDetector_html_a9564c3349f0fa5a7da7968b9461e2730"><div class="ttname"><a href="classLaneDetector.html#a9564c3349f0fa5a7da7968b9461e2730">LaneDetector::plotLane</a></div><div class="ttdeci">int plotLane(cv::Mat inputImage, std::vector&lt; cv::Point &gt;, std::string turn)</div><div class="ttdoc">This function plots both sides of the lane, the turn prediction message and a transparent polygon tha...</div><div class="ttdef"><b>Definition:</b> LaneDetector.cpp:279</div></div>
<div class="ttc" id="classLaneDetector_html_a8005c489f194eded3bc5a76cfc496c43"><div class="ttname"><a href="classLaneDetector.html#a8005c489f194eded3bc5a76cfc496c43">LaneDetector::lineSeparation</a></div><div class="ttdeci">std::vector&lt; std::vector&lt; cv::Vec4i &gt; &gt; lineSeparation(std::vector&lt; cv::Vec4i &gt; lines, cv::Mat img_edges)</div><div class="ttdoc">Sort all the detected Hough lines by slope. </div><div class="ttdef"><b>Definition:</b> LaneDetector.cpp:124</div></div>
<div class="ttc" id="classLaneDetector_html_ac9a862f41a23ab0c3bfed2ce512a56d8"><div class="ttname"><a href="classLaneDetector.html#ac9a862f41a23ab0c3bfed2ce512a56d8">LaneDetector::regression</a></div><div class="ttdeci">std::vector&lt; cv::Point &gt; regression(std::vector&lt; std::vector&lt; cv::Vec4i &gt; &gt; left_right_lines, cv::Mat inputImage)</div><div class="ttdoc">Regression takes all the classified line segments initial and final points and fits a new lines out o...</div><div class="ttdef"><b>Definition:</b> LaneDetector.cpp:181</div></div>
<div class="ttc" id="classLaneDetector_html_a64d74d2971d1e14175ef58dfbb391f6d"><div class="ttname"><a href="classLaneDetector.html#a64d74d2971d1e14175ef58dfbb391f6d">LaneDetector::mask</a></div><div class="ttdeci">cv::Mat mask(cv::Mat img_edges)</div><div class="ttdoc">Mask the image so that only the edges that form part of the lane are detected. </div><div class="ttdef"><b>Definition:</b> LaneDetector.cpp:82</div></div>
<div class="ttc" id="classLaneDetector_html_a8920b291267aad638f8874512fba33cf"><div class="ttname"><a href="classLaneDetector.html#a8920b291267aad638f8874512fba33cf">LaneDetector::edgeDetector</a></div><div class="ttdeci">cv::Mat edgeDetector(cv::Mat img_noise)</div><div class="ttdoc">Detect all the edges in the blurred frame by filtering the image. </div><div class="ttdef"><b>Definition:</b> LaneDetector.cpp:51</div></div>
<div class="ttc" id="classLaneDetector_html_adbbc2f50aee10844aeec12b1fe084fb2"><div class="ttname"><a href="classLaneDetector.html#adbbc2f50aee10844aeec12b1fe084fb2">LaneDetector::houghLines</a></div><div class="ttdeci">std::vector&lt; cv::Vec4i &gt; houghLines(cv::Mat img_mask)</div><div class="ttdoc">Obtain all the line segments in the masked images which are going to be part of the lane boundaries...</div><div class="ttdef"><b>Definition:</b> LaneDetector.cpp:106</div></div>
<div class="ttc" id="classLaneDetector_html"><div class="ttname"><a href="classLaneDetector.html">LaneDetector</a></div><div class="ttdoc">Definition of the LaneDetector class. It contains all the functions and variables depicted in the...</div><div class="ttdef"><b>Definition:</b> LaneDetector.hpp:37</div></div>
<div class="ttc" id="classLaneDetector_html_a84053373ae184e752f023658fb187241"><div class="ttname"><a href="classLaneDetector.html#a84053373ae184e752f023658fb187241">LaneDetector::predictTurn</a></div><div class="ttdeci">std::string predictTurn()</div><div class="ttdoc">Predict if the lane is turning left, right or if it is going straight. </div><div class="ttdef"><b>Definition:</b> LaneDetector.cpp:252</div></div>
<div class="ttc" id="classLaneDetector_html_a816d7555c6b7690d7afdd81eb62dd35b"><div class="ttname"><a href="classLaneDetector.html#a816d7555c6b7690d7afdd81eb62dd35b">LaneDetector::deNoise</a></div><div class="ttdeci">cv::Mat deNoise(cv::Mat inputImage)</div><div class="ttdoc">Apply gaussian filter to the input image to denoise it. </div><div class="ttdef"><b>Definition:</b> LaneDetector.cpp:37</div></div>
</div><!-- fragment --></div><!-- contents -->
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>
Generated by &#160;<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/>
</a> 1.8.11
</small></address>
</body>
</html>
